package com.entrogy.dao;


import com.entrogy.bean.DepartmentEntity;
import com.entrogy.bean.PositionEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface DepartmentMapper {
    @Insert("insert into department(sid) select school_id from user")
    int getSchoolId(@Param("sid") int sid);

    @Insert("insert into department (department_name,description,create_time,update_time,school_code) values(#{department_name},#{description},now(),now(),#{school_code})")
    int insertDepartment(DepartmentEntity departmentEntity);

    @Update("update department set department_name = #{department_name}, description = #{description}, update_time = now() where department_id = #{department_id}")
    int updateDepartment(DepartmentEntity departmentEntity);

    @Delete("delete from department WHERE department_id = #{department_id} ")
    int deleteDepartment(@Param("department_id") int department_id);

    /**
     *
     * @param map  获取部门的查询列表
     * @return
     */
    List<Map<String,Object>> selectDepartmentByT(Map<String,Object> map);

    /**
     *
     * @param map  获取部门的查询列表  根据条件查询条数
     * @return
     */
    int  countDepartment(Map<String,Object> map);

    /**
     *  获取职位列表
     * @return
     */
    List<PositionEntity> getPositionList(Map<String,Object> map);

    /**
     *   分页查询总数
     * @param map
     * @return
     */
    int  getTotalPositionList(Map<String,Object> map);

    /**
     *  修改职位名称
     * @return
     */
    int  updatePositionById(PositionEntity positionEntity);

    /**
     *  根据Id  查询对象
     * @param id
     * @return
     */
    PositionEntity  getPositionById(int id);

    /**
     *   新增基础数据
     * @param schoolCode
     * @return
     */
      int  insertPositions(@Param(value="schoolCode") int schoolCode);

    /**
     *  删除基础数据
     * @param schoolCode
     * @return
     */
      int deleteBySchoolCode(@Param(value="schoolCode") int schoolCode);

    /**
     *  selectPositionId
     * @param map
     * @return
     */
    int selectPositionId(Map<String,Object> map);
}
